package com.newbingo.service;

import com.newbingo.dao.imple.IAgentDao;
import com.newbingo.dao.imple.IOperatorDao;
import com.newbingo.dto.OperatorDto;
import com.newbingo.entity.Agent;
import com.newbingo.entity.Operator;
import com.newbingo.service.imple.IOperatorService;
import com.newbingo.util.Pager;
import com.newbingo.dto.imple.IOperatorDto;

public class OperatorService implements IOperatorService {
	
	private IOperatorDao operatorDao=null;
	private IOperatorDto operatorDto=null;
	private IAgentDao agentDao=null;

	public IOperatorDao getOperatorDao() {
		return operatorDao;
	}

	public void setOperatorDao(IOperatorDao operatorDao) {
		this.operatorDao = operatorDao;
	}

	public IOperatorDto getOperatorDto() {
		return operatorDto;
	}

	public void setOperatorDto(IOperatorDto operatorDto) {
		this.operatorDto = operatorDto;
	}

	/*
	 * 删除(non-Javadoc)
	 * @see com.newbingo.service.imple.IOperatorService#delete(com.newbingo.entity.Operator)
	 */
	public void delete(Operator instance) {
		operatorDao.delete(instance);

	}

	/*
	 * 根据ID 查询(non-Javadoc)
	 * @see com.newbingo.service.imple.IOperatorService#findById(java.lang.Integer)
	 */
	public OperatorDto findById(Integer Id) {
		return operatorDto.findById(Id);
	}
	
	/*
	 * ID 查询 返回Operator对象(non-Javadoc)
	 * @see com.newbingo.service.imple.IOperatorService#findById(java.lang.Integer)
	 */
	public Operator findByOperatorId(Integer Id){
		return operatorDao.findById(Id);
	}

	/*
	 * 查询(non-Javadoc)
	 * @see com.newbingo.service.imple.IOperatorService#findOperator(int, int, java.lang.Integer)
	 */
	public Pager findOperator(int start, int limit, Integer agentId) {
		return operatorDto.findOperator(start, limit, agentId);
	}

	/*
	 * 修改(non-Javadoc)
	 * @see com.newbingo.service.imple.IOperatorService#merge(com.newbingo.entity.Operator)
	 */
	public Operator merge(Operator instance) {
		return operatorDao.merge(instance);
	}

	/*
	 * 保存(non-Javadoc)
	 * @see com.newbingo.service.imple.IOperatorService#save(com.newbingo.entity.Operator)
	 */
	public void save(Operator instance) {
		Agent agent=agentDao.findById(instance.getAgent().getUno());
		instance.setAgent(agent);
        operatorDao.save(instance);
	}

	public IAgentDao getAgentDao() {
		return agentDao;
	}

	public void setAgentDao(IAgentDao agentDao) {
		this.agentDao = agentDao;
	}

	public OperatorDto findByLogin(String uname, String upwd) {
		return operatorDto.findByLogin(uname, upwd);
	}

}
